#include <stdio.h>

#define MAX_ROWS 10

void printPascalTriangle(int n) {
    int triangle[MAX_ROWS][MAX_ROWS];
    
    // 初始化杨辉三角形
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i)
                triangle[i][j] = 1;
            else
                triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];
        }
    }
    
    // 打印杨辉三角形
    for (int i = 0; i < n; i++) {
        
        // 输出数字
        for (int j = 0; j <= i; j++) {
            printf("%4d", triangle[i][j]);
        }
        printf("\n");
    }
}

int main() {
    int n;
    
    printf("input n (n<=10):\n");
    scanf("%d", &n);
    
    if (n <= 0 || n > MAX_ROWS) {
        printf("Invalid input. Please enter a number between 1 and 10.\n");
        return 1;
    }
    
    printPascalTriangle(n);
    
    return 0;
}
